# docker build -t yiyanweb:v1.0 .
# ----------docker run -it --rm -p 8000:80 --name yiyanweb yiyanweb:v1.0
# ----------docker run -it -p 8000:80 -e MYSQL_ROOT_PASSWORD=123456 --name yiyanweb yiyanweb:v1.0
# 需要安装docker高版本
# docker network create nginx_bridge
# docker run -d -p 80:80 -p 81:81 -v /d/dockerv/nginx/www:/usr/share/nginx/html -v /d/dockerv/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /d/dockerv/nginx/logs:/var/log/nginx --restart always --name nginx --network nginx_bridge --network-alias nginx nginx:1.19.3
# apk add curl

# docker run  -itd -p 7812:80 -v /d/dockerv/yiyanweb/conf/appsettings.json:/app/appsettings.json -v /d/dockerv/yiyanweb/files:/app/Files -v /d/dockerv/yiyanweb/logs:/app/logs --restart always --name yiyanweb --network nginx_bridge --network-alias yiyanweb yiyanweb:v1.0
# apt install net-tools # ifconfig
# apt install iputils-ping # ping
# docker run -p 8080:8080 -e ADMINER_DEFAULT_SERVER=mysql adminer:4.7
# docker run  -itd -p 7811:8080 -e ADMINER_PLUGINS='dump-zip' -e ADMINER_DEFAULT_SERVER='db' --restart always --name adminer --network nginx_bridge --network-alias adminer adminer:4.7
# ENV ASPNETCORE_URLS=http://+:80

# 删除 exited container
# docker rm -v $(docker ps -a -q -f status=exited)
#  删除没用的 image # dangling=true 按照中文来翻译的话，意思是指『悬空』的 image，我理解成『没有被使用的 image』。
# docker rmi $(docker images -f "dangling=true" -q)
#  删除没用的 volumn
# docker volume rm $(docker volume ls -qf dangling=true)

FROM kingreatwill/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /src
COPY ["Enter.Admin/Enter.Admin.csproj", "Enter.Admin/"]
RUN dotnet restore "Enter.Admin/Enter.Admin.csproj"
COPY . .
WORKDIR "/src/Enter.Admin"
RUN dotnet build "Enter.Admin.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Enter.Admin.csproj" -c Release -o /app/publish

FROM base AS final
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Enter.Admin.dll"]